﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;
using DAL;

namespace BAL
{
    public class DoPost
    {
        public static bool insertpost(string pname, string pcontent, string ptime, string pusername)
        {
            Post post = new Post(pname, pcontent, ptime, pusername);
            DALPost dalpost = new DALPost(post);
            return dalpost.insertpost();

        }

        public static List<Model.Post> searchresult(string strquery)
        {
            List<Model.Post> postlist = new List<Model.Post>();
            DAL.DALPost dalpost = new DAL.DALPost(null);
            postlist = dalpost.searchlist(strquery);
            return postlist;
        }

        public static int deletepost(string id)
        {
            DALPost dalpost = new DALPost(null);
            return dalpost.delpost(id);
        }

        public static int modifypost(Model.Post post)
        {
            DAL.DALPost dalpost = new DAL.DALPost(post);
            return dalpost.modifypost(post);
        }
        

        public static Dictionary<string, string> getpost(int postid)
        {
            DAL.DALPost dalpost = new DAL.DALPost(null);
            Dictionary<string, string> MyPost = dalpost.GetThePost(postid);
            return MyPost;
        }
        public static int getminpost()
        {
            DAL.DALPost dalpost = new DAL.DALPost(null);
            return dalpost.getminpost();
        }

        public static int getmaxpost()
        {
            DAL.DALPost dalpost = new DAL.DALPost(null);
            return dalpost.getmaxpost();
        }
        public static bool checkpostid(int id)
        {
            DAL.DALPost dalpost = new DAL.DALPost(null);
            return dalpost.checkpostid(id);
        }
    }
}
